/**
 * Copyright (C), 2018 store
 * Encoding: UTF-8
 * Date: 19-9-30 上午11:35
 * History:
 */
package com.swak.frame.hystrix.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.core.annotation.AliasFor;

import com.swak.frame.command.annotation.SwakExecutionType;
import com.swak.frame.command.annotation.SwakFallback;
import com.swak.frame.hystrix.event.FallbackEvent;
import com.swak.frame.hystrix.event.HystrixAlarmEvent;

/**
 * @ClassName: SwakHystrix.java
 * @author: colley.ma
 * @date: 2022/01/21
 */
@Documented
@Target({java.lang.annotation.ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@SwakFallback
public @interface SwakHystrix {

    @AliasFor(annotation = SwakFallback.class)
    String fallbackMethod() default "";

    abstract int coreSize() default 10;

    abstract int maximumSize() default 15;

    abstract int maxQueueSize() default 100;

    abstract int queueSizeRejectionThreshold() default 5;

    abstract String threadPoolKey() default "";

    /**
     * 超时时间 default 3s
     * 
     * @return milliseconds
     */
    abstract int timeout() default 3000;

    /**
     * fallback最大请求数
     * 
     * @return
     */
    abstract int fallbackMaxRequest() default Integer.MAX_VALUE;

    /**
     * 是否开启超时，默认开启
     * 
     * @return
     */
    abstract boolean timeoutEnabled() default true;

    @AliasFor(annotation = SwakFallback.class)
    abstract SwakExecutionType async() default SwakExecutionType.SYNCHRONOUS;

    abstract Class<? extends FallbackEvent> event() default HystrixAlarmEvent.class;

}
